Function.RegisterNamespace("System.IO");

System.IO.File=new function(){
    var _strategyManager;

    // Public Members
    this.Strategies;
    
    // ctor
    function File(){
        this.Strategies=_strategyManager=new System.Script.Strategy.StrategyManager();
    }
    File.apply(this,arguments);
    
    // Public Methods
    this.DeleteFile=function(path){
        if(path==undefined||!Object.IsType(Function,path.toString))throw new Error("System.IO.File.DeleteFile: 'path' must be convertible to String.");
        path=path.toString();
        if(this.Exists(path)){
            try{
                return _strategyManager.Get(this).DeleteFile(path);
            }catch(e){
                throw new Error(String.Format("System.IO.File.DeleteFile: {0}",e));
            }
        }
    };

    this.Exists=function(path){
        if(path==undefined||!Object.IsType(Function,path.toString))throw new Error("System.IO.File.Exists: 'path' must be convertible to String.");
        path=path.toString();
        try{
            return _strategyManager.Get(this).Exists(path);
        }catch(e){
            throw new Error(String.Format("System.IO.File.Exists: {0}",e));
        }
    };
    
    this.GetFile=function(path){
        if(path==undefined||!Object.IsType(Function,path.toString))throw new Error("System.IO.File.GetFile: 'path' must be convertible to String.");
        path=path.toString();
        try{
            return _strategyManager.Get(this).GetFile(path);
        }catch(e){
            throw new Error(String.Format("System.IO.File.GetFile: {0}",e));
        }
    };

    this.SaveFile=function(path,text){
        if(path==undefined||!Object.IsType(Function,path.toString))throw new Error("System.IO.File.SaveFile: 'path' must be convertible to String.");
        path=path.toString();
        try{
            _strategyManager.Get(this).SaveFile(path,text+'');
            return true;
        }catch(e){
            return false;
        }
    };
};

System.IO.File.constructor.Implement(System.IO.FileStrategy.IFileStrategy,'System.IO.File');